<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>发帖</title>
<jsp:include page="/WEB-INF/public/jquery-header.jsp"></jsp:include>
<jsp:include page="/WEB-INF/public/bootstarp-header.jsp"></jsp:include>
<jsp:include page="/WEB-INF/public/ueditor-header.jsp"></jsp:include>
</head>
<script type="text/javascript">
	var ue = null;
	var mid = -1;//板块选择
	function postTopic() {
		if(mid == -1){
			alert("请选择发帖对应的板块！！！");
			return ;
		}
		var title = $("#title").val();
		if(title == ""){
			alert("请输入标题！！！");
			return ;
		}
		var content = ue.getContent();
		if(content == ""){
			alert("请输入内容！！！");
			return ;
		}
		$.post("${pageContext.request.contextPath}/topic/post", {
			content:content,title:title,mid:mid
		}, function(data) {
			alert(data.msg);
		});
	}
	function changemid(id,str){
		mid = id;
		$("#menu").html("当前板块："+str+"   ");
	}
</script>
<body>
	<jsp:include page="/WEB-INF/public/head.jsp"></jsp:include>
	<header class="jumbotron subhead" style="background-color: #6f5499;color: white;">
	<div class="container">
		<h1>KisChang的博客</h1>
		<p class="lead">致力于Java开发推广，坚持分享、开放的互联网精神</p>
	</div>
	</header>
<div class="row">
  <div class="col-md-10 col-md-offset-1">
    <div class="input-group">
      <div class="input-group-btn">
        <button type="button" class="btn btn-default dropdown-toggle" style="width: 180px;" data-toggle="dropdown"><span id="menu">选择板块：</span><span class="caret"></span></button>
        <ul class="dropdown-menu" >
        <s:iterator value="menulist">
        	<s:if test="childs.size() == 0">
        		<li><a href="javascript:void(0)" onclick="changemid(<s:property value='id' />,'<s:property value='name' />')"><s:property value="name" /></a></li>
        		<li class="divider"></li>
        	</s:if>
        	<s:else>
        		<li><a href="javascript:void(0)" onclick="changemid(<s:property value='id' />,'<s:property value="name" />')"><s:property value="name" /></a></li>
	        	<s:iterator value="childs">
        		<li><a href="javascript:void(0)" onclick="changemid(<s:property value='id' />,'<s:property value="name" />')"><s:property value="name" /></a></li>
	        	</s:iterator>
	        	<li class="divider"></li>
        	</s:else>
        </s:iterator>
        </ul>
      </div>
      <input type="text" class="form-control" name="title" id="title">
    </div>
  </div>
  </div>
	<div class="row">
  		<div class="col-md-10 col-md-offset-1" style="margin-top: 10px">
		<span style="font-size:14px">
			<script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
			<script type="text/javascript">
			ue = UE.getEditor('editor', {
				toolbars : [ [ 'forecolor', 'backcolor', 'indent',
						'italic', 'underline', 'bold', 'undo',
						'redo', "|", 'fontfamily', 'fontsize',
						'paragraph', "|", 'justifyleft',
						'justifyright', 'justifycenter',
						'justifyjustify', "|", 'strikethrough',
						'fontborder', 'formatmatch', "|", 'time',
						'date', "|", 'inserttitle', 'simpleupload',
						'insertimage', "|", 'link', 'emotion',
						'spechars', "|", 'print', 'preview' ] ],
				autoHeightEnabled : true,
				autoFloatEnabled : true,
				enableAutoSave : false});
			</script></span>
	<span class="btn btn-primary" onclick="postTopic();return false;">发表帖子</span>
	</div>
	</div>
</body>
</html>
